/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package utiles;

import java.io.File;
import javax.swing.JComponent;
import javax.swing.JFileChooser;

/**
 *
 * @author fcarou
 */
public class JFileChooserHelper
{
    public static String tomarRuta (JComponent parent, int tipo)
    {
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(tipo);
        
        int acepto;
        
        acepto = fc.showOpenDialog(parent);
        
        if (acepto == JFileChooser.APPROVE_OPTION)
            return fc.getSelectedFile().getAbsolutePath();
        
        return null;
    }
    
    public static File tomarArchivo (JComponent parent)
    {
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
        
        int acepto;
        
        acepto = fc.showOpenDialog(parent);
        
        if (acepto == JFileChooser.APPROVE_OPTION)
            return fc.getSelectedFile();
        
        return null;
    }
}
